{% extends "lbforum/base_site.html" %}

{% load i18n %}
{% load lbforum_filters %}
{% load lbforum_tags %}

{% block title %}{{  block.super }}{% endblock %}

{% block extra_header %}
	<link href="{{ STATIC_URL }}lbforum/scripts/jquery.uploadify/uploadify.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="{{ STATIC_URL }}lbforum/scripts/markitup/skins/markitup/style.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="{{ STATIC_URL }}lbforum/scripts/markitup/sets/bbcode/style.css" />
{% endblock %}

{% block content_right_bar %}
    {% if forum.description %}
        <div class="box">
            <div class="inner">
                {{forum.description}}
            </div>
        </div>
        <div class="sep20"></div>
    {% endif %}

    <div class="box">
        <div class="cell">{% trans "You may use" %}:</div>
        <div class="inner">
            &raquo; <a target="_blank" href="http://fluxbb.org/forums/help/bbcode/">BBCode</a>
            <br/>
            &raquo; <a target="_blank" href="http://fluxbb.org/forums/help/img/">Images</a>
        </div>
    </div>
{% endblock %}

{% block content_content %}
    <div class="box">
        <div class="cell">
            <span class="bigger">
                <a href="{% url lbforum_index %}">{{ LBFORUM_TITLE }}</a>
                <span class="chevron">&raquo;</span>
                <a href="{{ forum.get_absolute_url }}">{{ forum.name }}</a>
                {% if topic %}
                <span class="chevron">&raquo;</span>
                <a href="{{ topic.get_absolute_url }}">{{ topic.subject }}</a>
                {% endif %}
                <span> &raquo; </span>
                {% if is_new_post %}{% trans "Post new" %}{% else %}{% trans "Edit" %}{% endif %} {{ post_type }}
            </span> 
        </div>
        {% if preview %}
            <div class="cell">
                <div class="inner">
                    <div class="content topic_content">
                        {{form.cleaned_data.message|bbcode|safe}}
                    </div>
                </div>
            </div>
        {% endif %}
        <div class="inner">
            {% if form.errors %}
                <strong> {% trans "Please correct the errors below." %}  </strong>
                {{ form|form_all_error }}
                <br/>
            {% endif %}
            <form action="" accept-charset="utf-8" method="post" class="frm-form" id="post-form">
                <div class="hidden" id="hidden_fields">
                    {% csrf_token %} 
                </div>
                {% if topic_post%}
                    {{form.topic_type}} {{form.subject}}
                    <div class="sep10"></div>
                {% endif %}
                {{form.message}}
                <div class="sep10"></div>
                <div id="uploadify" class="multi-file-upload">
                    <input id="fileInput" name="file" type="file" />
                </div>

                <ul id="uploaded_files">
                </ul>
                <div class="sep10"></div>
                <input type="submit" class="super normal button" value="{% trans "Submit" %}" name="submit"/>
                <input type="submit" class="super normal button" value="{% trans "Preview" %}" name="preview"/>
            </form>
        </div>
    </div>
{% endblock %}

{% block footer_js %}
    <script type="text/javascript" src="{% url lbforum_lang_js %}"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/jquery.min.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/markitup/jquery.markitup.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/markitup/sets/bbcode/set.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/json2.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/jquery.uploadify/swfobject.js"></script>
	<script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/jquery.uploadify/jquery.uploadify.v2.1.0.min.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/simple_tpl.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/upload_attachment.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}lbforum/scripts/common.js"></script>
    <script type="text/javascript">
        mySettings['previewParserPath']='{% url markitup_preview %}';
	    $("#id_message").markItUp(mySettings);
        url_attachments_ajax_change_descn = "{% url attachments_ajax_change_descn %}";
        url_attachments_ajax_delete = "{% url attachments_ajax_delete %}";
        url_attachments_ajax_upload = "{% url attachments_ajax_upload %}";
		ify_uploader = '{{ STATIC_URL }}lbforum/scripts/jquery.uploadify/uploadify.swf';
		ify_script = '{% url attachments_uploadify %}';
		ify_cancelImg = '{{ STATIC_URL }}lbforum/styles/Oxygen/cancel.png';
		session_key = '{{ session_key }}';
        $(function() {
            {% for o in unpublished_attachments %}
            add_attachment({'id': '{{o.id}}','url': '{{o.file.url}}','fn': '{{o.org_filename}}','descn':'{{o.description}}'});
            {% endfor %}
            {% for o in post.attachments.all %}
            add_attachment({'id': '{{o.id}}','url': '{{o.file.url}}','fn': '{{o.org_filename}}','descn':'{{o.description}}'});
            {% endfor %}
        });
    </script>
    <script type="text/html" id="attachment_li_tmpl">
        <li id="attachment_<%=id%>" class="nb">
        <a class="filename" href="<%=url%>" target="_blank"><%=fn%></a>
        <span class="icon descn" style="">&nbsp;</span>
        <span style="display: none;">
        <input class="fld-descn" value="<%=descn%>"/>
        <a class="submit-descn" href="#">{% trans "submit" %}</a>
        </span>
        <span class="icon remove">&nbsp;</span>
        <span class="icon insert">&nbsp;</span>
        <span class="ext">&nbsp;</span>
        </li>
    </script>
{% endblock %}        
